package com.spring.aop;


import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class NotVeryUsefulAspect {

	@Pointcut("execution(* com.spring.service..*.*(..))")
	public void a() {
	}

	@Around("a()")
	public Object b(ProceedingJoinPoint pjp) throws Throwable {
		Object[] args = pjp.getArgs();
		try {
			System.out.println("入参=" + args.toString());
			long start = System.currentTimeMillis();
			Object result = pjp.proceed();
			System.out.println("耗时=" + (System.currentTimeMillis() - start));
			System.out.println("回参=" + args.toString());
			return result;
		} catch (Exception e) {
			return "";
		}
	}
}
